//
//  UILabel+PYFrame.m
//  xuexi
//
//  Created by Jim on 2018/4/21.
//  Copyright © 2018年 Jim. All rights reserved.
//

#import "UILabel+PYFrame.h"

@implementation UILabel (PYFrame)

- (CGFloat)py_width
{
    if ([self.text isValidString]) {
        
        CGRect rect = [self.text boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.font} context:nil];
        
        return ceil(rect.size.width);
    }
    
    NSLog(@"py_width = 0");
    
    return 0;
}

@end
